package com.example.observer.v1;

public class Main {

    public static void main(String[] args) {
        Child child = Child.getInstance();

        while (!child.isCry()){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("isCry="+child.isCry()+ ",等着");
        }
        System.out.println("isCry="+child.isCry()+ "快处理啊");
    }
}

class Child {
    private boolean cry=false;
    private static final Child child=new Child();

    private Child(){
    }

    public static Child getInstance(){
        return child;
    }



    public boolean isCry(){
        return cry;
    }

    public void wakeUp(){
        System.out.println("wuwuwuwu");
        child.cry=true;
    }
}
